/*
 * @Description: 
 * @Author: paddies
 * @Date: 2024-11-14 11:06:37
 * @LastEditors: paddies
 * @LastEditTime: 2025-08-16 00:37:37
 * @FilePath: /luntai-user-app/Users/paddies/Desktop/code/A-team/luntai/shared_components/lib/luntai-components/build-show-pay-info/buildChoosePayType.dart
 */
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shared_components/build-button/buildButton.dart';
import 'package:shared_components/build-input-password/buildInputPassword.dart';
import 'package:shared_components/build-radio-group/buildRadioGroup.dart';

buildChoosePayType(
    {String payType = '',
    String free = '0',
    Function? okCallBack,
    Function? passwordOkCallBack}) {
  var myPayType = "".obs;
  myPayType.value = payType;
  myPayType.value = 'YE';
  Get.bottomSheet(
      isScrollControlled: true,
      Container(
          padding: EdgeInsets.only(left: 10, right: 10, top: 20),
          decoration: new BoxDecoration(
            color: Colors.white,
            // new Radius.circular(20.0)
            borderRadius: new BorderRadius.only(
                topLeft: new Radius.circular(20.0),
                topRight: new Radius.circular(20.0)), //圆角
          ),
          height: 400,
          child: Obx(() => Container(
                width: double.infinity,
                height: double.infinity,
                // color: Colors.red,
                child: Column(children: [
                  Container(
                    width: double.infinity,
                    alignment: Alignment.center,
                    child: Text(
                      "支付方式",
                      style:
                          TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                    ),
                  ),
                  Expanded(
                      child: Container(
                    width: double.infinity,
                    height: double.infinity,
                    // color: Colors.yellow,
                    child: Column(
                      children: [
                        buildNewRadioGrou(
                            list: [
                              // {"label": "积分支付", "value": "JF"},
                              {"label": "余额支付", "icon": "ye", "value": "YE"},
                              {
                                "label": "支付宝支付",
                                "icon": "zhifubao",
                                "value": "ALI"
                              },
                              {
                                "label": "微信支付",
                                "value": "WX",
                                "icon": "weixin",
                              }
                            ],
                            // widthFactor: 3,
                            activeValue: myPayType.value,
                            onChange: (value) {
                              myPayType.value = value;
                              // onChangePayType(value)
                              // payType.value = value;
                              // if (onChange !=
                              //     null) {
                              //   onChange(value);
                              // }
                            }),
                      ],
                    ),
                  )),
                  Container(
                    width: double.infinity,
                    height: 80,
                    // color: Colors.blue,
                    padding: EdgeInsets.only(
                        top: 10, bottom: 10, left: 10, right: 10),
                    child: buildButton(
                        title: "确认",
                        onClick: () {
                          if (myPayType.value == "YE") {
                            buildInputPassword(
                                payType: "余额支付",
                                price: free,
                                onSuccess: (value) async {
                                  print("输入的密码是===");
                                  print(value);
                                  if (passwordOkCallBack != null) {
                                    passwordOkCallBack(myPayType.value, value);
                                  }
                                });
                            return;
                          }
                          if (okCallBack != null) {
                            okCallBack(myPayType.value);
                          }
                        },
                        colors: [Color(0xffF9110D), Color(0xffF9110D)]),
                  ),
                  SizedBox(
                    height: 20,
                  )
                ]),
              ))));
}
